﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NorthWind.Entity;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace NorthWind.DAO
{
    public class TbCliente_GEN
    {
        public static List<TbClienteBE> SelectAllTbCliente()
        {
            string ConnectionString = ConfigurationManager.ConnectionStrings["NorthWind"].ToString();            
            string sql = "SELECT CodCliente,Nombre,Ruc FROM TbCliente";
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(sql, connection))
                {
                    command.CommandType = CommandType.Text;
                    List<TbClienteBE> Clientes = new List<TbClienteBE>();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            TbClienteBE objTbCliente = new TbClienteBE();
                            objTbCliente.CodCliente = reader.GetDecimal(0);
                            objTbCliente.Nombre = reader.GetString(1);
                            objTbCliente.Ruc = reader.GetString(2);
                            Clientes.Add(objTbCliente);
                        }
                    }                   
                    return Clientes;
                }

            }
        }        
    }
}
